import { request } from '../request';

export function fetchRegistLayout(areaname: string, info: string) {
  return request.post<boolean>(`/machine/registLayout`, {
    areaname,
    info
  });
}

export function fetchLayout(areaname: string) {
  return request.get(`/machine/getLayout?areaname=${areaname}`);
}

export function fetchInspectionItemListByAreaAndMachine(areaname: string, machineName: string) {
  return request.get<Factory.InspectionItem[]>(
    `/machine/getInspectionItemListByAreaAndMachine?areaName=${areaname}&machineName=${machineName}`
  );
}

export function fetchSubmitInspectionResult(inspectionResults: Factory.InspectionResult[]) {
  return request.post<boolean>(`/inspection/submitInspectionResult`, inspectionResults);
}

export function fetchPmPlanByMachineName(machineName: string) {
  return request.get<Factory.PmMachinePlan[]>(`/machine/getPmPlanByMachine?machineName=${machineName}`);
}

export function fetchPmResultByMachineName(startTime: string, endTime: string, machineName: string) {
  return request.get<Factory.PmMachineResult[]>(
    `/machine/getPmResult?startTime=${startTime}&endTime=${endTime}&machineName=${machineName}`
  );
}

export function fetchInspectResultyMachineName(startTime: string, endTime: string, machineName: string) {
  return request.get<Factory.InspectionResult[]>(
    `/inspection/getInspectionResult?startTime=${startTime}&endTime=${endTime}&machineName=${machineName}`
  );
}

export function fetchMachineAlarm(startTime: string, endTime: string, machineName: string) {
  return request.get<Factory.MachineAlarm[]>(
    `/machine/getMachineAlarm?startTime=${startTime}&endTime=${endTime}&machineName=${machineName}`
  );
}

export function fetchMachineAlarmHis(alarmId: string) {
  return request.get<Factory.MachineAlarm[]>(`/machine/getMachineAlarmHis?alarmId=${alarmId}`);
}
